import fs from 'node:fs'
import downloadGit from 'download-git-repo'
import ora from 'ora'
const spiner = ora('下载中....')
//判断是否存在某一个目录
export const checkPath = (path) => {
  if (fs.existsSync(path)) {
    return true
  } else {
    return false
  }
}

//下载模版文件
export const downloadTmp = (branch, project) => {
  return new Promise((resolve, reject) => {
    spiner.start()
    downloadGit(`direct:https://gitee.com/chinafaker/vue-template.git#${branch}`, project, { clone: true }, function (err) {
      if (err) reject(err)
      resolve()
      spiner.succeed('下载完成')
    })
  })
}